import { SelectQueryBuilder } from "typeorm";

export function doSqlJoinOwner<T extends object>($qb: SelectQueryBuilder<T>, relations_name: string) {
  $qb
    .leftJoinAndSelect(`${relations_name}.justOwner`, "justOwner_doSqlJoinOwner")
    .leftJoinAndSelect(`justOwner_doSqlJoinOwner.justUserWeChat`, `justUserWeChat_doSqlJoinOwner`)
    .leftJoinAndSelect(`justOwner_doSqlJoinOwner.justUserEmail`, `justUserEmail_doSqlJoinOwner`);
  return $qb;
}

export function doSqlJoinCreator<T extends object>($qb: SelectQueryBuilder<T>, relations_name: string) {
  $qb
    .leftJoinAndSelect(`${relations_name}.justCreator`, "justCreator_doSqlJoinCreator")
    .leftJoinAndSelect(`justCreator_doSqlJoinCreator.justUserWeChat`, `justUserWeChat_doSqlJoinCreator`)
    .leftJoinAndSelect(`justCreator_doSqlJoinCreator.justUserEmail`, `justUserEmail_doSqlJoinCreator`);
  return $qb;
}
